function gcpick_writetoxlsx(data, config)
file = [config.resultpath, '/', config.resultExcelName];
N = length(data);
name = cell([N, 1]);
flag = zeros([N, 1]);
tp = flag;
ts= flag;
polarE = flag;
polarN = flag;
polarZ = flag;
for i = 1:N
    name{i} = data(i).station;
    flag(i) = data(i).flag;
    tp(i) = data(i).tp;
    ts(i) = data(i).ts;
    polarE(i) = data(i).polar.E;
    polarN(i) = data(i).polar.N;
    polarZ(i) = data(i).polar.Z;
end
t = table(name, flag, tp, ts, polarE, polarN, polarZ);
try
    writetable(t, file, 'FileType', 'spreadsheet');
catch
    disp('Error while writting to excel. Please check and try later.');
    return;
end
end